import { defineStore } from 'pinia'
import { computed, reactive, ref } from 'vue'

export const useGlobalStore = defineStore('global', () => {
  /** state */
  const token = ref<string>('') // token
  const permissionList = ref<string[]>([]) // 权限
  const userInfo = reactive({
    username: '',
    role: '',
  }) // 用户信息

  /** getter */
  const isLogin = computed(() => Boolean(token.value))

  // 导出
  return { token, isLogin, userInfo, permissionList }
})
